import React, { lazy } from 'react'
import { Navigate } from 'react-router-dom'
import { createFromIconfontCN } from '@ant-design/icons'
import Layout from '@/pages/Layout'
const Home = lazy(() => import('@/pages/Home/index'))
const User = lazy(() => import('@/pages/User/index'))
const DemoRedux = lazy(() => import('@/pages/DemoRedux/index'))
const Login = lazy(() => import('@/pages/Login/index'))
const Detail = lazy(() => import('@/pages/User/Detail'))
const SpacePage = lazy(() => import('@/pages/components/404'))
const IconFont = createFromIconfontCN({
  scriptUrl: '//at.alicdn.com/t/c/font_3555855_3x3ynam5jup.js'
})
const router = [
  {
    path: '/',
    element: <Navigate to='/home' />,
    hidden: true
  },
  {
    path: '/login',
    element: <Login />,
    hidden: true
  },
  {
    path: '*',
    element: <SpacePage />,
    hidden: true
  },
  {
    path: '/',
    element: <Layout />,
    children: [
      {
        label: '首页',
        key: '/home',
        path: '/home',
        element: <Home/>,
        icon: <IconFont type="icon-caiwu"/>
      },
      {
        label: 'DemoRedux',
        key: '/demo_redux',
        path: '/demo_redux',
        element: <DemoRedux/>
      },
      {
        label: '用户管理',
        icon: <IconFont type="icon-caiwu"/>,
        children: [
          {
            label: '账户列表',
            path: '/user',
            key: '/user',
            element: <User/>
          },
          {
            label: '',
            path: '/detail',
            key: '/detail',
            element: <Detail />,
            hidden: true
          }
        ]
      }
    ]
  }
]
export default router
